<template>
	<view class="u-content">
		<view class="initiate">
			<view class="initiate1">
				<view class="initiate11">
					{{}}发起了帮助
				</view>
				<view class="initiate12">
					2021年09月20日
				</view>
			</view>
			<view class="initiate2">
				720郑州特大暴雨灾情
			</view>
		</view>
<!-- demandId -->
<!-- help_feedback -->
		<view class="needGoods">
			<view class="needGoods1">
				本人急需物资紧急救援！
			</view>
			<view class="needGoods2">
				被服类(防雨符)1000件
				工具类(雨棚)500顶
				备 注：急需物资救援，减缓灾情
				个人信息：王松柏-18378997080-江西省南昌市高新区子古路111号
			</view>
		</view>

		<view class="helpInfo">
			<view class="helpInfo1">
				<image src="../../static/require/help.png" mode=""></image>
				<text>帮助信息</text>
			</view>
			<view class="helpInfo2">
				<view class="helpInfo21" v-for="(item,index) in items" :key="item.value" @click="selectHelp(index)">
					<view class="helpInfo211">
						<image :src="item.src" mode=""></image>
						<text>{{item.name}}</text>
					</view>
					<image v-if="index==n" src="../../static/require/mselect.png" mode=""></image>
					<image v-else src="../../static/require/noselect.png" mode=""></image>
				</view>
			</view>
		</view>
		
		<view class="empt">
		</view>
		
		<view class="confirm" @click="updateResultByDemandId">
			<view class="confirm1">
				<text>确认</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1,
				items: [{
						code: '1',
						name: '未得到救助',
						src: require('../../static/require/nohelp.png')
					},
					{
						code: '2',
						name: '得到部分救助',
						checked: 'true',
						src: require('../../static/require/somehelp.png')
					},
					{
						code: '3',
						name: '得到全部救助',
						src: require('../../static/require/allhelp.png')
					},
				],
				current: -1,
				n: -1,
				name:'',
				code:1,
				demandId:'XQ20211029000006'
			}
		},
		onLoad(){
			// this.updateResultByDemandId()
			this.selectDemandList()
		},
		methods: {
			selectDemandList(){
				this.$ajax({
					url:'/emergency_supplies/api/gft/donation/v1/donationHelpDemand/selectDemandList',
					method:'POST',
					contentType:'application/json;charset=utf-8',
				}).then(res =>{
					console.log(res)
				})
			},
			updateResultByDemandId(){
				this.$ajax({
					url:'/emergency_supplies/api/gft/donation/v1/donationHelpDemand/updateResultByDemandId',
					method:'POST',
					data:{
						code:this.code,
						demandId:this.demandId
					}
				}).then(res =>{
					console.log(res)
					if (res.code == 200) {
						uni.showToast({
							title: '提交成功！',
							icon: 'none'
						})
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
					
				})
			},
			selectHelp(index) {
				console.log(this.n)
				this.n = index;
				this.name=this.items[index].name
				if(this.n==-1){
					this.code=1
				}else if(this.n==0){
					this.code=2
				}
				else if(this.n==1){
					this.code=3
				}
				else if(this.n==2){
					this.code=4
				}
				console.log(this.name)
			},
		}
	}
</script>

<style scoped lang="scss">
	.u-content {
		.initiate {
			padding: 60rpx 30rpx;

			.initiate1 {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.initiate11 {
					font-size: 36rpx;
					line-height: 66rpx;
					color: #fe5745;
				}

				.initiate12 {
					font-size: 26rpx;
					line-height: 44rpx;
					color: #666666;
				}
			}

			.initiate2 {
				font-size: 26rpx;
				line-height: 44rpx;
				color: #666666;
			}
		}

		.needGoods {
			padding: 10rpx 50rpx;

			.needGoods1 {
				font-size: 34rpx;
				line-height: 66rpx;
				color: #333333;
			}

			.needGoods2 {
				font-size: 26rpx;
				line-height: 44rpx;
				color: #666666;
			}
		}

		.helpInfo {
			padding: 20rpx 30rpx;

			.helpInfo1 {
				image {
					width: 34rpx;
					height: 32rpx;
				}

				text {
					font-size: 34rpx;
					line-height: 66rpx;
					margin-left: 30rpx;
					color: #333333;
				}
			}

			.helpInfo2 {
				padding: 20rpx 30rpx;

				.helpInfo21 {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin: 40rpx 0;

					.helpInfo211 {
						display: flex;
						align-items: center;

						image {
							width: 80rpx;
							height: 80rpx;
						}

						text {
							font-size: 30rpx;
							line-height: 66rpx;
							color: #666666;
							margin-left: 30rpx;
						}
					}

					image {
						width: 37rpx;
						height: 37rpx;
					}
				}
			}
		}

		.empt {
			width: 100%;
			height: 150rpx;
		}

		.confirm {
			width: 100%;
			height: 150rpx;
			position: fixed;
			bottom: 0;
			background-color: #ffffff;

			.confirm1 {
				margin: 40rpx auto;
				width: 650rpx;
				height: 80rpx;
				background-color: #fe5745;
				border-radius: 10rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				text {
					font-size: 30rpx;
					line-height: 44rpx;
					color: #ffffff;
				}
			}
		}
	}
</style>
